package gui;

import io.Cliente;
import java.awt.Color;
import java.util.List;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import logica.Verificador;
import logica.VerificadorException;

/**
 *
 * @author Mariano Zapata
 */
public class PanelCliente extends javax.swing.JPanel implements DocumentListener, InterfazPestania {

    private RenderPestania renderPestania;
    private Cliente cliente;
    private boolean modificado;
    private PanelPestaniasControlador ppc;
    
    /** Creates new form PanelCliente */
    public PanelCliente(Cliente cliente, RenderPestania rp, PanelPestaniasControlador ppc)
    {
        initComponents();
        this.ppc= ppc;
        this.cliente= cliente;
        this.renderPestania= rp;
        modificado= true; //Para que el evento seleccionoItem no se ejecute al cargar los datos.
        this.renderPestania.setTitulo(this.cliente.toString());
        this.cargarDatos();
        modificado= false; //El panel queda en un estado correcto.
        this.initListeners();
    }
    
    @Override
    public void cerrar() {
        ppc.cerrarPestania(this);
    }
    
    public Cliente getCliente() {
        return cliente;
    }
    
    public Cliente validar() throws VerificadorException
    {
        try {
            this.desmarcarErrores();
            this.trim();
            Verificador.verificarCliente(apellido.getText(), nombre.getText(), dni.getText(), fechaNacimiento.getText(),
                    telefonoMovil.getText(), email.getText(), domicilioDireccion.getText(), domicilioCiudad.getText(),
                    domicilioProvincia.getText(), domicilioCodigoPostal.getText(), domicilioTelefono.getText(),
                    trabajoNombre.getText(), trabajoPuesto.getText(), trabajoDireccion.getText(), trabajoCiudad.getText(),
                    trabajoProvincia.getText(), trabajoCodigoPostal.getText(), trabajoTelefono.getText(),
                    trabajoFax.getText(), trabajoWeb.getText());
            cliente.setApellido(apellido.getText());
            if (dni.getText().isEmpty())
                cliente.setDni(-1);
            else
                cliente.setDni(Integer.parseInt(dni.getText()));
            Integer i= new Integer(estadoCivil.getSelectedIndex());
            cliente.setEstadoCivil(i.byteValue());
            cliente.setFechaNacimiento(fechaNacimiento.getText());
            cliente.setNombres(nombre.getText());
            cliente.setDomicilioDireccion(domicilioDireccion.getText());
            cliente.setDomicilioCiudad(domicilioCiudad.getText());
            cliente.setDomicilioProvincia(domicilioProvincia.getText());
            if (domicilioCodigoPostal.getText().isEmpty())
                cliente.setDomicilioCodigoPostal(-1);
            else
                cliente.setDomicilioCodigoPostal(Integer.parseInt(domicilioCodigoPostal.getText()));
            cliente.setDomicilioTelFijo(domicilioTelefono.getText());
            cliente.setTelMovil(telefonoMovil.getText());
            cliente.setEmail(email.getText());
            cliente.setTrabajoNombre(trabajoNombre.getText());
            cliente.setTrabajoPuesto(trabajoPuesto.getText());
            cliente.setTrabajoDireccion(trabajoDireccion.getText());
            cliente.setTrabajoCiudad(trabajoCiudad.getText());
            cliente.setTrabajoProvincia(trabajoProvincia.getText());
            cliente.setTrabajoWeb(trabajoWeb.getText());
            if (trabajoCodigoPostal.getText().isEmpty())
                cliente.setTrabajoCodigoPostal(-1);
            else
                cliente.setTrabajoCodigoPostal(Integer.parseInt(trabajoCodigoPostal.getText()));
            cliente.setTrabajoTelFijo(trabajoTelefono.getText());
            cliente.setTrabajoTelFax(trabajoFax.getText());
            cliente.setSeguimiento(seguimiento.getText());
            return cliente;
        } catch (VerificadorException ex) {this.marcarErrores(ex.obtenerErrores());
                                           throw ex;}
    }
    
    public void setGuardado()
    {
        if (modificado)
        {
            renderPestania.setTitulo(cliente.toString());
            renderPestania.modificado(false);
            modificado= false;
        }
    }
    
    public boolean estaModificado() {
        return modificado;
    }
    
    private void cargarDatos()
    {
        apellido.setText(cliente.getApellido());
        if (cliente.getDni() == -1)
            dni.setText("");
        else
            dni.setText(String.valueOf(cliente.getDni()));
        Byte b= new Byte(cliente.getEstadoCivil());
        estadoCivil.setSelectedIndex(b.intValue());
        fechaNacimiento.setText(cliente.getFechaNacimiento());
        nombre.setText(cliente.getNombres());
        domicilioDireccion.setText(cliente.getDomicilioDireccion());
        domicilioCiudad.setText(cliente.getDomicilioCiudad());
        domicilioProvincia.setText(cliente.getDomicilioProvincia());
        if (cliente.getDomicilioCodigoPostal() == -1)
            domicilioCodigoPostal.setText("");
        else
            domicilioCodigoPostal.setText(String.valueOf(cliente.getDomicilioCodigoPostal()));
        domicilioTelefono.setText(cliente.getDomicilioTelFijo());
        telefonoMovil.setText(cliente.getTelMovil());
        email.setText(cliente.getEmail());
        trabajoNombre.setText(cliente.getTrabajoNombre());
        trabajoPuesto.setText(cliente.getTrabajoPuesto());
        trabajoDireccion.setText(cliente.getTrabajoDireccion());
        trabajoCiudad.setText(cliente.getTrabajoCiudad());
        trabajoProvincia.setText(cliente.getTrabajoProvincia());
        trabajoWeb.setText(cliente.getTrabajoWeb());
        if (cliente.getTrabajoCodigoPostal() == -1)
            trabajoCodigoPostal.setText("");
        else
            trabajoCodigoPostal.setText(String.valueOf(cliente.getTrabajoCodigoPostal()));
        trabajoTelefono.setText(cliente.getTrabajoTelFijo());
        trabajoFax.setText(cliente.getTrabajoTelFax());
        seguimiento.setText(cliente.getSeguimiento());
    }
    
    private void trim()
    {
        apellido.setText(apellido.getText().trim());
        dni.setText(dni.getText().trim());
        fechaNacimiento.setText(fechaNacimiento.getText().trim());
        nombre.setText(nombre.getText().trim());
        domicilioDireccion.setText(domicilioDireccion.getText().trim());
        domicilioCiudad.setText(domicilioCiudad.getText().trim());
        domicilioProvincia.setText(domicilioProvincia.getText().trim());
        domicilioCodigoPostal.setText(domicilioCodigoPostal.getText().trim());
        domicilioTelefono.setText(domicilioTelefono.getText().trim());
        telefonoMovil.setText(telefonoMovil.getText().trim());
        email.setText(email.getText().trim());
        trabajoNombre.setText(trabajoNombre.getText().trim());
        trabajoPuesto.setText(trabajoPuesto.getText().trim());
        trabajoDireccion.setText(trabajoDireccion.getText().trim());
        trabajoCiudad.setText(trabajoCiudad.getText().trim());
        trabajoProvincia.setText(trabajoProvincia.getText().trim());
        trabajoWeb.setText(trabajoWeb.getText().trim());
        trabajoCodigoPostal.setText(trabajoCodigoPostal.getText().trim());
        trabajoTelefono.setText(trabajoTelefono.getText().trim());
        trabajoFax.setText(trabajoFax.getText().trim());
    }
    
    private void marcarErrores(List<Integer> errores)
    {
        for (int i : errores)
        {
            switch (i)
            {
                case Verificador.ERROR_CLIENTE_DNI: dni.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_APELLIDO: apellido.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_NOMBRE: nombre.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_FECHA_NACIMIENTO: fechaNacimiento.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TELEFONO_MOVIL: telefonoMovil.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_EMAIL: email.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_DOMICILIO_DIRECCION: domicilioDireccion.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_DOMICILIO_CIUDAD: domicilioCiudad.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_DOMICILIO_PROVINCIA: domicilioProvincia.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_DOMICILIO_CODIGO_POSTAL: domicilioCodigoPostal.setBackground(Color.red);
                                                                        break;
                case Verificador.ERROR_CLIENTE_DOMICILIO_TELEFONO: domicilioTelefono.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_NOMBRE: trabajoNombre.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_PUESTO: trabajoPuesto.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_DIRECCION: trabajoDireccion.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_CIUDAD: trabajoCiudad.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_PROVINCIA: trabajoProvincia.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_CODIGO_POSTAL: trabajoCodigoPostal.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_TELEFONO: trabajoTelefono.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_FAX: trabajoFax.setBackground(Color.red); break;
                case Verificador.ERROR_CLIENTE_TRABAJO_WEB: trabajoWeb.setBackground(Color.red); break;
            }
        }
    }
    
    private void desmarcarErrores()
    {
        dni.setBackground(Color.white);
        apellido.setBackground(Color.white);
        nombre.setBackground(Color.white);
        fechaNacimiento.setBackground(Color.white);
        telefonoMovil.setBackground(Color.white);
        email.setBackground(Color.white);
        domicilioDireccion.setBackground(Color.white);
        domicilioCiudad.setBackground(Color.white);
        domicilioProvincia.setBackground(Color.white);
        domicilioCodigoPostal.setBackground(Color.white);
        domicilioTelefono.setBackground(Color.white);
        trabajoNombre.setBackground(Color.white);
        trabajoPuesto.setBackground(Color.white);
        trabajoDireccion.setBackground(Color.white);
        trabajoCiudad.setBackground(Color.white);
        trabajoProvincia.setBackground(Color.white);
        trabajoCodigoPostal.setBackground(Color.white);
        trabajoTelefono.setBackground(Color.white);
        trabajoFax.setBackground(Color.white);
        trabajoWeb.setBackground(Color.white);
    }
    
    @Override
    public String toString() {
        return cliente.toString();
    }
    
    @Override
    public void insertUpdate(DocumentEvent e) {
        if (!modificado)
        {
            renderPestania.modificado(true);
            modificado= true;
        }
    }

    @Override
    public void removeUpdate(DocumentEvent e) {
        if (!modificado)
        {
            renderPestania.modificado(true);
            modificado= true;
        }
    }

    @Override
    public void changedUpdate(DocumentEvent e) {
        if (!modificado)
        {
            renderPestania.modificado(true);
            modificado= true;
        }
    }
    
    private void initListeners()
    {
        apellido.getDocument().addDocumentListener(this);
        dni.getDocument().addDocumentListener(this);
        domicilioCiudad.getDocument().addDocumentListener(this);
        domicilioCodigoPostal.getDocument().addDocumentListener(this);
        domicilioDireccion.getDocument().addDocumentListener(this);
        domicilioProvincia.getDocument().addDocumentListener(this);
        domicilioTelefono.getDocument().addDocumentListener(this);
        email.getDocument().addDocumentListener(this);
        fechaNacimiento.getDocument().addDocumentListener(this);
        nombre.getDocument().addDocumentListener(this);
        seguimiento.getDocument().addDocumentListener(this);
        telefonoMovil.getDocument().addDocumentListener(this);
        trabajoCiudad.getDocument().addDocumentListener(this);
        trabajoCodigoPostal.getDocument().addDocumentListener(this);
        trabajoDireccion.getDocument().addDocumentListener(this);
        trabajoFax.getDocument().addDocumentListener(this);
        trabajoNombre.getDocument().addDocumentListener(this);
        trabajoProvincia.getDocument().addDocumentListener(this);
        trabajoPuesto.getDocument().addDocumentListener(this);
        trabajoTelefono.getDocument().addDocumentListener(this);
        trabajoWeb.getDocument().addDocumentListener(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        apellido = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        dni = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        estadoCivil = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        fechaNacimiento = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        nombre = new javax.swing.JTextField();
        domicilioDireccion = new javax.swing.JTextField();
        domicilioCiudad = new javax.swing.JTextField();
        domicilioProvincia = new javax.swing.JTextField();
        email = new javax.swing.JTextField();
        telefonoMovil = new javax.swing.JTextField();
        domicilioTelefono = new javax.swing.JTextField();
        domicilioCodigoPostal = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        trabajoNombre = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        trabajoPuesto = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        trabajoDireccion = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        trabajoCiudad = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        trabajoProvincia = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        trabajoWeb = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        trabajoCodigoPostal = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        trabajoTelefono = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        trabajoFax = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        seguimiento = new javax.swing.JTextArea();

        setMinimumSize(new java.awt.Dimension(848, 494));

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos personales:"));

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel2.setText("Apellido:");
        jLabel2.setPreferredSize(new java.awt.Dimension(102, 14));

        apellido.setToolTipText("Formato: sólo letras (obligatorio).");

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel3.setText("DNI/LC/LE:");
        jLabel3.setPreferredSize(new java.awt.Dimension(102, 14));

        dni.setToolTipText("Formato: sólo números (opcional).");

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("Estado Civil:");
        jLabel4.setPreferredSize(new java.awt.Dimension(102, 14));

        estadoCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "(Desconocido)", "Soltero(a)", "Casado(a)", "Divorciado(a)", "Viudo(a)" }));
        estadoCivil.setToolTipText("Seleccione una opción.");
        estadoCivil.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                seleccionoItem(evt);
            }
        });

        jLabel5.setText("Fecha de nacimiento:");

        fechaNacimiento.setToolTipText("Formato: dd/mm/aaaa (opcional).");

        jLabel9.setText("Provincia:");

        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel8.setText("Ciudad:");

        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel7.setText("Dirección:");

        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel6.setText("Nombre:");

        nombre.setToolTipText("Formato: sólo letras (obligatorio).");

        domicilioDireccion.setToolTipText("Formato: letras y números (opcional).");

        domicilioCiudad.setToolTipText("Formato: sólo letras (opcional).");

        domicilioProvincia.setToolTipText("Formato: sólo letras (opcional).");

        email.setToolTipText("Formato: usuario@dominio (opcional).");

        telefonoMovil.setToolTipText("Formato: código de área (opcional) + número de teléfono móvil (opcional).");

        domicilioTelefono.setToolTipText("Formato: código de área (opcional) + número de teléfono fijo (opcional).");

        domicilioCodigoPostal.setToolTipText("Formato: sólo números (opcional).");

        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel13.setText("Código postal:");

        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel12.setText("Teléfono fijo:");

        jLabel11.setText("Teléfono móvil:");

        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel10.setText("E-mail:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(estadoCivil, 0, 170, Short.MAX_VALUE)
                    .addComponent(fechaNacimiento, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(dni, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(apellido, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE))
                .addGap(26, 26, 26)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(domicilioProvincia, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(domicilioCiudad, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(domicilioDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(nombre, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE))
                .addGap(26, 26, 26)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(email, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(telefonoMovil, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(domicilioTelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(domicilioCodigoPostal, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(estadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(fechaNacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel13)
                                    .addComponent(domicilioCodigoPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel12)
                                    .addComponent(domicilioTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(31, 31, 31))
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel11)
                                .addComponent(telefonoMovil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel6)
                                    .addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel7)
                                    .addComponent(domicilioDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel8)
                                    .addComponent(domicilioCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel9)
                                .addComponent(domicilioProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel10)
                                .addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos laborales:"));

        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel14.setText("Nombre:");
        jLabel14.setPreferredSize(new java.awt.Dimension(102, 14));

        trabajoNombre.setToolTipText("Formato: sólo letras (opcional).");

        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel15.setText("Puesto:");
        jLabel15.setPreferredSize(new java.awt.Dimension(102, 14));

        trabajoPuesto.setToolTipText("Formato: sólo letras (opcional).");

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel1.setText("Dirección:");
        jLabel1.setPreferredSize(new java.awt.Dimension(102, 14));

        trabajoDireccion.setToolTipText("Formato: letras y números (opcional).");

        jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel16.setText("Ciudad:");
        jLabel16.setPreferredSize(new java.awt.Dimension(47, 14));

        trabajoCiudad.setToolTipText("Formato: sólo letras (opcional).");

        jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel17.setText("Provincia:");

        trabajoProvincia.setToolTipText("Formato: sólo letras (opcional).");

        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel18.setText("Web:");

        trabajoWeb.setToolTipText("<html>Formato: se debe especificar el protocolo y luego el dominio.<br>Ej1.: http://estudio-juridico.com<br>Ej2.: https://estudio-juridico.com</html>");

        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel19.setText("Código postal:");

        trabajoCodigoPostal.setToolTipText("Formato: sólo números (opcional).");

        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel20.setText("Teléfono fijo:");

        trabajoTelefono.setToolTipText("Formato: código de área (opcional) + número de teléfono fijo (opcional).");

        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel21.setText("Teléfono fax:");

        trabajoFax.setToolTipText("Formato: código de área (opcional) + número de teléfono de fax (opcional).");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(trabajoDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(trabajoPuesto, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(trabajoNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
                    .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(trabajoWeb, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(trabajoProvincia, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(trabajoCiudad, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE))
                .addGap(31, 31, 31)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel19))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(trabajoFax, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
                    .addComponent(trabajoTelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
                    .addComponent(trabajoCodigoPostal, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel19)
                            .addComponent(trabajoCodigoPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel20)
                            .addComponent(trabajoTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel21)
                            .addComponent(trabajoFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(trabajoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(trabajoCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(trabajoPuesto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel17)
                            .addComponent(trabajoProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(trabajoDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel18)
                            .addComponent(trabajoWeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Otros datos:"));

        seguimiento.setColumns(20);
        seguimiento.setFont(new java.awt.Font("Monospaced", 0, 12));
        seguimiento.setLineWrap(true);
        seguimiento.setRows(5);
        seguimiento.setWrapStyleWord(true);
        jScrollPane1.setViewportView(seguimiento);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 796, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void seleccionoItem(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_seleccionoItem
        if (!modificado)
        {
            renderPestania.modificado(true);
            modificado= true;
        }
    }//GEN-LAST:event_seleccionoItem

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField apellido;
    private javax.swing.JTextField dni;
    private javax.swing.JTextField domicilioCiudad;
    private javax.swing.JTextField domicilioCodigoPostal;
    private javax.swing.JTextField domicilioDireccion;
    private javax.swing.JTextField domicilioProvincia;
    private javax.swing.JTextField domicilioTelefono;
    private javax.swing.JTextField email;
    private javax.swing.JComboBox estadoCivil;
    private javax.swing.JTextField fechaNacimiento;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField nombre;
    private javax.swing.JTextArea seguimiento;
    private javax.swing.JTextField telefonoMovil;
    private javax.swing.JTextField trabajoCiudad;
    private javax.swing.JTextField trabajoCodigoPostal;
    private javax.swing.JTextField trabajoDireccion;
    private javax.swing.JTextField trabajoFax;
    private javax.swing.JTextField trabajoNombre;
    private javax.swing.JTextField trabajoProvincia;
    private javax.swing.JTextField trabajoPuesto;
    private javax.swing.JTextField trabajoTelefono;
    private javax.swing.JTextField trabajoWeb;
    // End of variables declaration//GEN-END:variables
}
